import axios from "axios";
const  request = axios.create({
    timeout: 5000
})
//请求
request.interceptors.request.use(config =>{
    config.headers['Content-Type']  = 'application/json;charset=utf-8';
    return config;
},error => {
    return Promise.reject(error);
});
//响应
request.interceptors.response.use(response =>{
    let resp= response.data;
    if(response.config.responseType === 'blog'){
        return resp;
    }
    if(typeof  resp === 'string'){
        resp = resp ? JSON.parse(resp) : resp;
    }
    return resp;
},error => {
    console.log("error--->"+error);
    return Promise.reject(error);
})
export default request;
